package com.mareas.web.jsf.view;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.jsf.FacesContextUtils;

import com.mareas.web.model.Operacion;
import com.mareas.web.model.OperacionEstado;
import com.mareas.web.service.GenericService;

@Component("mainBean")
@ManagedBean
@RequestScoped
public class MainBean {

	@Autowired
	private GenericService genericService;
	private Operacion operacionActual;

	public GenericService getGenericService() {
		return genericService;
	}

	public void setGenericService(GenericService genericService) {
		this.genericService = genericService;
	}

	public String getRefreshMain() {
		return "/page/main";
	}

	public Operacion getOperacionActual() {
		if (this.operacionActual == null) {
			FacesContext facescontext = FacesContext.getCurrentInstance();
			ApplicationBean applicationBean = (ApplicationBean) FacesContextUtils
					.getRequiredWebApplicationContext(facescontext).getBean(
							"applicationBean");
			this.operacionActual = applicationBean.getOperacionActual();
			
		}
		return this.operacionActual;
	}

	public void setOperacionActual(Operacion operacionActual) {
		this.operacionActual = operacionActual;
	}

	
}
